package nf.action;

import nf.dao.CellPhoneDao;
import nf.dao.CellPhoneDaoImpl;
import nf.entity.CellPhone;
import nf.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/loginServlet")
public class loginServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String username = request.getParameter("username");
        String name = request.getParameter("name");
        String password = request.getParameter("password");

        User user = new User();
        user.setPassword(password);
        user.setUserName(username);
        user.setName(name);

        CellPhoneDao dao = new CellPhoneDaoImpl();
        boolean kk = dao.adduser(user);

        response.sendRedirect("index.jsp");
    }
}
